package mysql


type Table struct {
	Schema    string `xorm:"'TABLE_SCHEMA'"`
	Name      string `xorm:"'TABLE_NAME'"`
	Collation string `xorm:"'TABLE_COLLATION'"`
	Comment   string `xorm:"'TABLE_COMMENT'"`
}

func (Table) TableName() string {
	return "TABLES"
}

func (t Table) getTables(repo *Repo) (items []Table, err error) {
	items=make([]Table,0)
	if t.Name!=""{
		if err = repo.engine.Where("TABLE_SCHEMA=? and TABLE_NAME=?",t.Schema,t.Name).Find(&items); err != nil {
			return nil, err
		}
	}else{
		if err = repo.engine.Where("TABLE_SCHEMA=? ",t.Schema).Find(&items); err != nil {
			return nil, err
		}
	}


	return items, nil
}
